package app.server.project.main.service.dto.upay.tron;

import lombok.Data;
import org.tron.trident.abi.datatypes.Address;
import org.tron.trident.utils.Numeric;

@Data
public class USDContractParamVal {
    private String data;


    public long getAmount() {
        var value = data.substring(72);
        return Numeric.toBigInt(value).longValue();
    }

    public String getToAddress() {
        var toAddress = data.substring(8, 72);
        toAddress = toAddress.replaceFirst("^0+(?!$)", "");
        return new Address(toAddress).toString();
    }
}
